<?php

namespace App\Http\Requests\Mini\Meter;


use Illuminate\Foundation\Http\FormRequest;

/**
 * 电表设备表单验证
 * @SDD
 * Class ElectricMeter
 * @package App\Http\Requests\Mini\Meter
 */
class ElectricMeter extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * 2021/3/10--13:13
     * @return string[]
     * @author:苏冬冬
     * @method:rules
     * @effect: 添加采集器验证
     */
    public function rules()
    {
        return [
            'name' => 'required',//电表名称
            'code' => ['required','regex:/^[a-z\d]*$/i'],//电表资产编号
            'tableAddress' => ['required','regex:/^[0-9]+$/','size:12'],//表地址
//            'community' => ['required'],//表地址
            'collect_id' => 'required',//采集器id
            'cate' => 'required',//接入象限

        ];
    }

    /**
     * @return array|void
     */
    public function messages()
    {
        return [
            'name.required' => '请填写电表名称',
            'code.required' => '请填写电表资产编码',
            'code.regex' => '资产编码必须为字母或数字组合',
            'tableAddress.required' => '请填写表地址',
            'tableAddress.regex' => '表地址必须由数字组成',
            'tableAddress.size' => '表地址必须为12位',
            'collect_id.required' => '请选择采集器id',
//            'community.required' => '请选择区域',
            'cate.required' => '请选择接入象限',
        ];
    }
}
